<?php
class PeopleController extends CommonController
{
	public function index()
	{
		$peopleCls = new PeopleModel($this->uid);
		$people = $peopleCls->getAll();
		
		$this->view->assign('title', '人员管理');
		$this->view->assign('People', $people);
		$this->view->setPlace('content', 'place/people');
		$this->view->display();
	}
	
	/**
	 * 添加资产账户
	 */
	public function add()
	{
		$do = Functions::gpc('do', 'p');
		$peopleCls = new PeopleModel($this->uid);
		if($do == 'save')
		{
			$data['UID'] = $this->uid;
			$data['PeopleName'] = Functions::sqlgpc('PeopleName', 'p');
			$data['PeopleType'] = Functions::sqlgpc('PeopleType', 'p');
			$data['PeopleType'] = intval($data['PeopleType']);
			$data['PeopleType'] = $data['PeopleType'] == 1 || $data['PeopleType'] == 0 ? $data['PeopleType'] : 1;
			$data['Status'] = Functions::sqlgpc('Status', 'p');
			$data['CreateDate'] = time();
			$data['Remark'] = Functions::sqlgpc('Remark', 'p');
			$peopleCls->add($data);
		}
		$this->view->assign('People', $peopleCls->getAll());
		
	    if($this->isAjax)
		{
		    $this->view->setUseLayout(false);
		}
		else
		{
		    $this->view->setPlace('content', 'page/people/add');
		}
		
		$this->view->display();
	}
	
	public function __destruct()
	{
		//echo 'index controller destruct!<br />';
	}
}